package main

import (
	"fmt"
)

func main() {
	fmt.Println("Are you Ok!")
	arrLength()
	arrTwo()
	fmt.Println()
	showArr()
	fmt.Println()
	showArrLength()
	fmt.Println("showArrTwo")
	showArrTwo()
	fmt.Println("数组是值类型")
	arrByValue()
	fmt.Println("数组赋值")
	arrByTwo()

}

func arrByTwo() {
	arr := [...]string{"Go", "身体", "存款", "家庭"}
	copy := arr
	copy[0] = "Go微服务架构师"
	fmt.Println(arr)
	fmt.Println(copy)
}

func arrByValue() {
	arr := [...]string{"Go语言", "微服务架构师", "Go语言的核心", "多练习，早日入门"}
	copy := arr
	copy[0] = "Golang"
	fmt.Println(arr)
	fmt.Println(copy)
}

func showArrTwo() {
	arr := [...]string{"Go语言", "python", "php", "java"}
	for index, value := range arr {
		fmt.Println(index, value)
	}

	fmt.Println()
	for _, value := range arr {
		fmt.Println(value)
	}
}

func showArrLength() {
	arr := [...]string{"Go语言入门", "Go语言熟悉", "Go语言精通"}
	for index, value := range arr {
		fmt.Println(index, value)
	}

	fmt.Println()
	for _, value := range arr {
		fmt.Println(value)
	}
}

func showArr() {
	arr := [...]string{"Go语言", "python", "php", "java"}
	for index, value := range arr {
		fmt.Printf("arr[%d] = %s \n", index, value)
	}

	fmt.Println("方法二")
	for _, value := range arr {
		fmt.Printf("value = %s \n", value)
	}
}

// 数组的长度
func arrTwo() {
	arr := [...]string{"保重身体", "存钱做长远的计划", "减少花销", "学习技能", "增加收入"}
	//fmt.Println(arr)
	fmt.Println("arr:", len(arr))
}

func arrLength() {
	arr := [...]string{"Go语言入门", "Go语言熟悉", "Go语言精通"}
	fmt.Println("arr length:", len(arr))
}
